Global Index
HTML5 JS API Index > DOM Tutorials & Specs

Element

Extends Node. Implements ParentNode, NonDocumentTypeChildNode, ChildNode.

Extended by HTMLElement, Element (Pointer Lock), Element (Fullscreen), Element (Selectors), Element (Shadow DOM), Element (CSS Object Model), SVGElement, SVGElement

Element nodes are simply known as elements.

Properties
Attr[]
attributes
The attributes attribute must return a read only array of the context object's attribute list. The returned read only array must be live. I.e. changes to the associated attributes are reflected.
unsigned long
childElementCount
The childElementCount attribute must return the number of children of the context object that are elements.
HTMLCollection
children
The children attribute must return an HTMLCollection collection rooted at the context object matching only element children.
DOMTokenList
classList
The classList attribute must return the associated DOMTokenList object representing the context object's classes.
DOMString
className
The className attribute must reflect the "class" content attribute.
Element?
firstElementChild
The firstElementChild attribute must return the first child that is an element, and null otherwise.
DOMString
id
The id attribute must reflect the "id" content attribute.
Element?
lastElementChild
The lastElementChild attribute must return the last child that is an element, and null otherwise.
DOMString
localName
The localName attribute must return the context object's local name.
DOMString?
namespaceURI
The namespaceURI attribute must return the context object's namespace.
Element?
nextElementSibling
The nextElementSibling attribute must return the first following sibling that is an element, and null otherwise.
DOMString?
prefix
The prefix attribute must return the context object's namespace prefix.
Element?
previousElementSibling
The previousElementSibling attribute must return the first preceding sibling that is an element, and null otherwise.
DOMString
pseudo
Represents the custom pseudo-element value, associated with the element.
ShadowRoot?shadowRoot
DOMStringtagName
Operations
voidafter((Node or DOMString) nodes...)
voidappend((Node or DOMString) nodes...)
voidbefore((Node or DOMString) nodes...)
ShadowRoot
createShadowRoot()
When invoked, these steps must be run: If the context object is not an element, throw an InvalidNodeTypeError.Otherwise: Create a new instance of the ShadowRoot objectEstablish the context object as the shadow host of the ShadowRoot objectAdd the ShadowRoot object at the top of the tree stack of its hostReturn ShadowRoot object.
DOMString?getAttribute(DOMString name)
DOMString?getAttributeNS(DOMString? namespace, DOMString localName)
HTMLCollection
getElementsByClassName(DOMString classNames)
The getElementsByClassName(classNames) method must return the list of elements with class names classNames for the context object.
HTMLCollection
getElementsByTagName(DOMString localName)
The getElementsByTagName(localName) method must return the list of elements with local name localName for the context object.
HTMLCollection
getElementsByTagNameNS(DOMString? namespace, DOMString localName)
The getElementsByTagNameNS(namespace, localName) method must return the list of elements with namespace namespace and local name localName for the context object.
booleanhasAttribute(DOMString name)
booleanhasAttributeNS(DOMString? namespace, DOMString localName)
boolean
matches(DOMString selectors)
The matches(selectors) method must return true if the context object is in the result of running match a selectors string selectors against a set consisting of context object, and false otherwise.
voidprepend((Node or DOMString) nodes...)
PseudoElement?pseudo(DOMString pseudoElt)
Element?
query(DOMString relativeSelectors)
The query(relativeSelectors) method must return the first result of running match a relative selectors string relativeSelectors against a set consisting of context object, and null if the result is an empty list.
Elements
queryAll(DOMString relativeSelectors)
The queryAll(relativeSelectors) method must return an Elements array initialized with the result of running match a relative selectors string relativeSelectors against a set consisting of context object.
Element (Selectors)?
querySelector(DOMString selectors)
The querySelector() methods on the Document, DocumentFragment, and Element interfaces must return the first matching Element node within the subtrees of the context node. If there is no matching Element, the method must return null.
Element?
querySelector(DOMString selectors)
The querySelector(selectors) method must return the first result of running scope-match a selectors string selectors against the context object, and null if the result is an empty list otherwise.
NodeList
querySelectorAll(DOMString selectors)
The querySelectorAll() methods on the Document, DocumentFragment, and Element interfaces must return a NodeList containing all of the matching Element nodes within the subtrees of the context node, in document order. If there are no matching nodes, the method must return an empty NodeList.
NodeList
querySelectorAll(DOMString selectors)
The querySelectorAll(selectors) method must return the static result of running scope-match a selectors string selectors against the context object.
voidremove()
voidremoveAttribute(DOMString name)
voidremoveAttributeNS(DOMString? namespace, DOMString localName)
voidreplace((Node or DOMString) nodes...)
voidrequestFullscreen()
void
requestPointerLock()
Requests that the pointer be locked to a DOM element target. The user agent determines if pointer lock state will be entered and upon lock state change or error must send either a pointerlockchange or pointerlockerror event respectively.
voidsetAttribute(DOMString name, DOMString value)
voidsetAttributeNS(DOMString? namespace, DOMString name, DOMString value)
Referenced by
CanvasRenderingContext2DdrawSystemFocusRing(...)
DataTransfersetDragImage(...)
DocumentquerySelector(...)
DocumentFragmentquerySelector(...)
DrawingStyleDrawingStyle(...)
Elementsquery(...)
HitRegionOptionscontrol
HTMLCollectionnamedItem(...)
HTMLDialogElementshowModal(...)
HTMLFormElementgetter(...)
HTMLSelectElementitem(...)
NodeparentElement
NonDocumentTypeChildNodepreviousElementSibling
NonElementParentNodegetElementById(...)
ParentNodequerySelector(...)
ShadowRootelementFromPoint(...)
StyleSheetownerNode
SVGSVGElementgetElementById(...)
WindowgetComputedStyle(...)